/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package justdoit.view;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import justdoit.controller.LanguageManager;

/**
 * A small dialog to introduce the application, just like other about dialogs.
 * @author Can
 */
public class AboutDialog extends JDialog {

    private JLabel teamLable;
    private JLabel[] teamMembers;
    private JLabel separator;
    private JPanel aboutPanel;
    private JButton okButton;
    private final int width = 500;

    public AboutDialog() {
        initComponents();
    }

    private void initComponents() {
        teamLable = new JLabel(LanguageManager.getString("label.aboutMenuItemText"));
        separator = new JLabel("--------------------------------------------------------------");
        teamMembers = new JLabel[5];
        teamMembers[0] = new JLabel("Cui Nenghui - nenghui.cui.6161@student.uu.se\n");
        teamMembers[1] = new JLabel("Aliev, Dilshod - Dilshod.Aliev.1565@student.uu.se\n");
        teamMembers[2] = new JLabel("Rahim, Muhanad - Muhanad.Abdul_Rahim.0047@student.uu.se\n");
        teamMembers[3] = new JLabel("Neelam Jagadish, Rajalakshmi - Rajalakshmi.Neelam_Jagadish.5274@student.uu.se\n");
        teamMembers[4] = new JLabel("Ekdemir, Sadan - sekdemir@gmail.com\n");

        for (JLabel jLabel : teamMembers) {
            jLabel.setSize(width, 10);
        }

        okButton = new JButton(LanguageManager.getString("button.ok"));
        okButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                AboutDialog.this.dispose();
            }
        });

        aboutPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

        aboutPanel.add(teamLable);
        aboutPanel.add(separator);
        for (JLabel jLabel : teamMembers) {
            aboutPanel.add(jLabel);
        }

        this.setLayout(new BorderLayout());
        this.add(BorderLayout.CENTER, aboutPanel);
        this.add(BorderLayout.SOUTH, okButton);

        this.getRootPane().setDefaultButton(okButton);

        this.setModal(true);
        this.setResizable(false);
        this.setSize(width, 250);
        this.setLocationRelativeTo(null);
        this.setTitle(LanguageManager.getString("title.aboutDialog"));
    }
}
